#pragma once


class CTaggerDialog : public CDialogImpl<CTaggerDialog>
	, public CDialogResize<CTaggerDialog>
	, public CWinDataExchange<CTaggerDialog>
{
public:
	enum { IDD = IDD_DIALOG_TAGGER };

	CTaggerDialog(metadb_handle_list_cref p_handles, const pfc::string_list_const & p_strings)
		: m_handles(p_handles)
		, m_strings(p_strings)
	{
	}

	virtual ~CTaggerDialog() {}

	void DeleteSelected();

	LRESULT OnInitDialog(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);

	void OnFinalMessage(HWND wnd)
	{
		delete this;
	}

	LRESULT OnClose(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
	{
		DestroyWindow();

		return FALSE;
	}

	LRESULT OnBnClickedButtonUpdate(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled);

	LRESULT OnBnClickedButtonClose(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled)
	{
		DestroyWindow();

		return FALSE;
	}

	LRESULT OnLvnItemchangedListFiles(int idCtrl, LPNMHDR pnmh, BOOL& bHandled);

	//LRESULT OnLvnBeginlabeleditListFiles(int idCtrl, LPNMHDR pnmh, BOOL& bHandled);

	LRESULT OnLvnKeydownListFiles(int idCtrl, LPNMHDR pnmh, BOOL& bHandled);


	BEGIN_MSG_MAP(CTaggerDialog)
		MESSAGE_HANDLER(WM_INITDIALOG, OnInitDialog)
		MESSAGE_HANDLER(WM_CLOSE, OnClose)
		NOTIFY_HANDLER(IDC_LIST_FILES, LVN_KEYDOWN, OnLvnKeydownListFiles)
		NOTIFY_HANDLER(IDC_LIST_FILES, LVN_ITEMCHANGED, OnLvnItemchangedListFiles)
		//NOTIFY_HANDLER(IDC_LIST_FILES, LVN_BEGINLABELEDIT, OnLvnBeginlabeleditListFiles)
		COMMAND_HANDLER(IDC_BUTTON_CLOSE, BN_CLICKED, OnBnClickedButtonClose)
		COMMAND_HANDLER(IDC_BUTTON_UPDATE, BN_CLICKED, OnBnClickedButtonUpdate)
		CHAIN_MSG_MAP(CDialogResize<CTaggerDialog>)
	END_MSG_MAP()

	BEGIN_DDX_MAP(CTaggerDialog)
		DDX_CONTROL_HANDLE(IDC_LIST_FILES, m_files)
	END_DDX_MAP()

	BEGIN_DLGRESIZE_MAP(CTaggerDialog)
		// ListViews and GroupBoxs
		// Files
		DLGRESIZE_CONTROL(IDC_GROUP_FILES, DLSZ_SIZE_X | DLSZ_SIZE_Y)
		DLGRESIZE_CONTROL(IDC_LIST_FILES, DLSZ_SIZE_X | DLSZ_SIZE_Y)
		// Previews
		DLGRESIZE_CONTROL(IDC_GROUP_PREVIEW, DLSZ_SIZE_X | DLSZ_MOVE_Y)
		DLGRESIZE_CONTROL(IDC_EDIT_PREVIEW, DLSZ_SIZE_X | DLSZ_MOVE_Y)

		// Buttons
		DLGRESIZE_CONTROL(IDC_BUTTON_UPDATE, DLSZ_MOVE_X | DLSZ_MOVE_Y)
		DLGRESIZE_CONTROL(IDC_BUTTON_CLOSE, DLSZ_MOVE_X | DLSZ_MOVE_Y)
	END_DLGRESIZE_MAP()

private:
	metadb_handle_list m_handles;
	pfc::string_list_impl m_strings;
	pfc::list_t<const metadb_handle *> m_skipped;

	CListViewCtrl	m_files;
};
